#alternate user interface designed by zigbert.
#120203 rodin.s: internationalized.
#120224 more gettext's required. icons were missing.
#120224 handle translated help.htm
#120225 fix for translated categories.
#120504 some files moved into /tmp/petget
#120508 01micko: bugfix. ref: http://murga-linux.com/puppy/viewtopic.php?p=625843#625843
#120515 calls to /tmp/petget/filterpkgs.results.postfilter.sh replace by /usr/local/petget/postfilterpkgs.sh.
#120529 app icons in tree. variable FLG_APPICONS created in pkg_chooser.sh
#120811 category field now supports sub-category |category;subcategory|, use as icon in ppm main window.
#130330 GUI filter. see also filterpkgs.sh, pkg_chooser.sh, ui_Ziggy.
#130331 more GUI filter options.

export TEXTDOMAIN=petget___ui_Ziggy
export OUTPUT_CHARSET=UTF-8

ALLITEM='' ; ALLSTOCK='' ; CATHEIGHT='100' ; WINHEIGHT='380'
if [ "$ALLCATEGORY" != "" ];then
 ALLITEM="<item stock=\"gtk-ALL\">$(gettext 'ALL')</item>"
 ALLSTOCK='stock["gtk-ALL"] = {{ "pet24.png", *, *, *}}'
 CATHEIGHT='112'
 WINHEIGHT='388'
fi

touch /var/local/petget/bb_category
if [ "`cat /var/local/petget/bb_category`" = "true" ]; then
  BBITEM="<item stock=\"gtk-BB\">$(gettext 'BuildingBlock')</item>"
else
  BBITEM=""
fi

APPICONXMLINSERT=' icon-column="1"' #120811 each line is format: abiword0-1.2.3|subcategory|description of abiword|stuff

#120224 handle translated help.htm
LANG1="${LANG%_*}" #ex: de
HELPFILE="/usr/local/petget/help.htm"
[ -f /usr/local/petget/help-${LANG1}.htm ] && HELPFILE="/usr/local/petget/help-${LANG1}.htm"

#120225 fix translated categories...
CATTRANSTABLE="Desktop:$(gettext 'Desktop') 
System:$(gettext 'System')
Setup:$(gettext 'Setup')
Utility:$(gettext 'Utility')
Filesystem:$(gettext 'Filesystem')
Graphic:$(gettext 'Graphic')
Document:$(gettext 'Document')
Business:$(gettext 'Business')
Personal:$(gettext 'Personal')
Network:$(gettext 'Network')
Internet:$(gettext 'Internet')
Multimedia:$(gettext 'Multimedia')
Fun:$(gettext 'Fun')
BuildingBlock:$(gettext 'BuildingBlock')
ALL:$(gettext 'ALL')"
echo "#!/bin/sh
CATTRANSTABLE='${CATTRANSTABLE}'" > /tmp/ppm-ui-ziggy-fix
echo 'CATEGORY="`echo "$CATTRANSTABLE" | grep "$1" | head -n 1 | cut -f 1 -d ':'`"
[ ! "$CATEGORY" ] && CATEGORY="Desktop"
echo "$CATEGORY"
' >> /tmp/ppm-ui-ziggy-fix
chmod 755 /tmp/ppm-ui-ziggy-fix

DEFGUIFILTER="$(cat /var/local/petget/gui_filter)" #130330 see pkg_chooser.sh, and below.

#130330 $GUIONLYSTR $ANYTYPESTR are exported from pkg_chooser.sh.  130331 also $GUIEXCSTR $NONGUISTR
export MAIN_DIALOG="<window title=\"$(gettext 'Puppy Package Manager')\" icon-name=\"gtk-about\" default_height=\"${WINHEIGHT}\" default_width=\"680\">
<hbox>
 <vbox>
  <hbox>
   <button tooltip-text=\"$(gettext 'Uninstall packages')\">
    <label>$(gettext 'Uninstall')</label>
    <input file icon=\"mini-trash\"></input>
    <action>launch:INSTALLED_DIALOG</action>
   </button>
   <button tooltip-text=\"$(gettext 'Configure package manager')\">
    <input file stock=\"gtk-preferences\"></input>
    <action>/usr/local/petget/configure.sh</action>
    <action>/usr/local/petget/filterpkgs.sh</action>
    <action>refresh:TREE1</action>
   </button>
   <button tooltip-text=\"$(gettext 'Help')\">
    <input file stock=\"gtk-help\"></input>
    <action>defaulthtmlviewer file://${HELPFILE} & </action>
   </button>
   <button type=\"exit\"  tooltip-text=\"$(gettext 'Quit package manager')\">
    <input file stock=\"gtk-quit\"></input>
   </button>
   </hbox>


 <frame $(gettext 'Repositories')>
  <vbox scrollable=\"true\">
   ${DB_ORDERED}
   <height>128</height>
  </vbox>
 </frame>
 
   
 <frame $(gettext 'Package types')>
 <hbox>
  <vbox>
   <checkbox>
    <default>${DEF_CHK_EXE}</default>
    <label>EXE</label>
    <variable>CHK_EXE</variable>
    <action>/usr/local/petget/postfilterpkgs.sh EXE \$CHK_EXE</action>
    <action>refresh:TREE1</action>
   </checkbox>
   <checkbox>
    <default>${DEF_CHK_DEV}</default>
    <label>DEV</label>
    <variable>CHK_DEV</variable>
    <action>/usr/local/petget/postfilterpkgs.sh DEV \$CHK_DEV</action>
    <action>refresh:TREE1</action>
   </checkbox>
   <checkbox>
    <default>${DEF_CHK_DOC}</default>
    <label>DOC</label>
    <variable>CHK_DOC</variable>
    <action>/usr/local/petget/postfilterpkgs.sh DOC \$CHK_DOC</action>
    <action>refresh:TREE1</action>
   </checkbox>
   <checkbox>
    <default>${DEF_CHK_NLS}</default>
    <label>NLS</label>
    <variable>CHK_NLS</variable>
    <action>/usr/local/petget/postfilterpkgs.sh NLS \$CHK_NLS</action>
    <action>refresh:TREE1</action>
   </checkbox>
  </vbox>
  <vbox>
   <comboboxtext width-request=\"140\">
    <variable>FILTERCOMBOBOX</variable>
    <default>$DEFGUIFILTER</default>
    <item>$ANYTYPESTR</item>
    <item>$GUIONLYSTR</item>
    <item>GTK+2 $GUIONLYSTR</item>
    <item>GTK+3 $GUIONLYSTR</item>
    <item>Qt4 $GUIONLYSTR</item>
    <item>Qt4 $GUIEXCSTR KDE</item>
    <item>Qt5 $GUIONLYSTR</item>
    <item>Qt5 $GUIEXCSTR KDE</item>
    <item>$NONGUISTR</item>
    <action>echo -n \"\$FILTERCOMBOBOX\" > /var/local/petget/gui_filter</action>
    <action>/usr/local/petget/filterpkgs.sh</action>
    <action>refresh:TREE1</action>
   </comboboxtext>
  </vbox>
 </hbox> 
 </frame>

  <hbox width-request=\"100\">
   <text><label>$(gettext 'Find:')</label></text>
   <entry activates-default=\"true\">
    <variable>ENTRY1</variable>
   </entry>
   <button can-default=\"true\" has-default=\"true\" use-stock=\"true\">
    <label>$(gettext 'Go')</label>
    <action>/usr/local/petget/findnames.sh</action>
    <action>refresh:TREE1</action>
    <action>/usr/local/petget/show_installed_version_diffs.sh & </action>
   </button>
  </hbox>
</vbox>  
  
<vbox>
   <tree>
   <label>$(gettext 'Category')</label>
   <variable>CATEGORY</variable>
   <item stock=\"gtk-Desktop\">$(gettext 'Desktop')</item>
   <item stock=\"gtk-System\">$(gettext 'System')</item>
   <item stock=\"gtk-Setup\">$(gettext 'Setup')</item>
   <item stock=\"gtk-Utility\">$(gettext 'Utility')</item>
   <item stock=\"gtk-Filesystem\">$(gettext 'Filesystem')</item>
   <item stock=\"gtk-Graphic\">$(gettext 'Graphic')</item>
   <item stock=\"gtk-Document\">$(gettext 'Document')</item>
   <item stock=\"gtk-Business\">$(gettext 'Business')</item>
   <item stock=\"gtk-Personal\">$(gettext 'Personal')</item>
   <item stock=\"gtk-Network\">$(gettext 'Network')</item>
   <item stock=\"gtk-Internet\">$(gettext 'Internet')</item>
   <item stock=\"gtk-Multimedia\">$(gettext 'Multimedia')</item>
   <item stock=\"gtk-Fun\">$(gettext 'Fun')</item>
   ${BBITEM}
   ${ALLITEM}
   <width>140</width><height>${CATHEIGHT}</height>
   <action signal=\"changed\">/tmp/ppm-ui-ziggy-fix \$CATEGORY | xargs -I CATINSERT /usr/local/petget/filterpkgs.sh CATINSERT</action>
   <action signal=\"changed\">refresh:TREE1</action>
  </tree>
</vbox>
  <tree column-resizeable=\"false|false\">
    <label>$(gettext 'Package|Description')</label>
    <variable>TREE1</variable>
    <input${APPICONXMLINSERT}>cat /tmp/petget/filterpkgs.results.post</input>
    <action>/usr/local/petget/installpreview.sh</action>
    <action>/usr/local/petget/finduserinstalledpkgs.sh</action>
    <action>refresh:TREE2</action>
    <action signal=\"button-release-event\">/usr/local/petget/installpreview.sh</action>
    <action signal=\"button-release-event\">/usr/local/petget/finduserinstalledpkgs.sh</action>
    <action signal=\"button-release-event\">refresh:TREE2</action>
  </tree>

</hbox>
</window>"

export INSTALLED_DIALOG='<window title="'$(gettext 'Uninstall Puppy Package')'" icon-name="gtk-about" default_height="380" default_width="450">
 <vbox>
  <text><label>'$(gettext 'Click on an item in the list to uninstall package')'</label></text>  
  <tree column-resizeable="false|false">
    <label>'$(gettext 'Installed Package|Description')'</label>
    <variable>TREE2</variable>
    <input'${APPICONXMLINSERT}'>cat /tmp/petget/installedpkgs.results.post</input>
    <action>/usr/local/petget/removepreview.sh</action>
    <action>/usr/local/petget/finduserinstalledpkgs.sh</action>
    <action>refresh:TREE2</action>
    <action signal="button-release-event">/usr/local/petget/removepreview.sh</action>
    <action signal="button-release-event">/usr/local/petget/finduserinstalledpkgs.sh</action>
    <action signal="button-release-event">refresh:TREE2</action>
  </tree>
  </vbox>
</window>' 

mkdir -p /tmp/puppy_package_manager
ln -s /usr/local/lib/X11/pixmaps/*48.png /tmp/puppy_package_manager 2>/dev/null
echo 'style "icon-style" {
	stock["gtk-Desktop"] = {{ "x48.png", *, *, *}}
	stock["gtk-System"]	= {{ "pc48.png", *, *, *}}
	stock["gtk-Setup"] = {{ "configuration48.png", *, *, *}}
	stock["gtk-Utility"] = {{ "utility48.png", *, *, *}}
	stock["gtk-Filesystem"] = {{ "folder48.png", *, *, *}}
	stock["gtk-Graphic"] = {{ "paint48.png", *, *, *}}
	stock["gtk-Document"] = {{ "word48.png", *, *, *}}
	stock["gtk-Business"] = {{ "spread48.png", *, *, *}}
	stock["gtk-Personal"] = {{ "date48.png", *, *, *}}
	stock["gtk-Network"] = {{ "connect48.png", *, *, *}}
	stock["gtk-Internet"] = {{ "www48.png", *, *, *}}
	stock["gtk-Multimedia"] = {{ "multimedia48.png", *, *, *}}
	stock["gtk-Fun"] = {{ "games48.png", *, *, *}}
	stock["gtk-BB"] = {{ "pet48.png", *, *, *}}
	'${ALLSTOCK}'}
class "GtkWidget" style "icon-style"' > /tmp/puppy_package_manager/gtkrc_ppm

export GTK2_RC_FILES=/root/.gtkrc-2.0:/tmp/puppy_package_manager/gtkrc_ppm

export TEXTDOMAIN=petget___pkg_chooser.sh
